package com.fivestar.pmanager.dao.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import com.fivestar.pmanager.core.mapper.DBActionMapper;
import com.fivestar.pmanager.core.mapper.PaginatingMapper;
import com.fivestar.pmanager.model.SysRoleOperationRelaBean;

/**
 * 用户角色操作关系
 * SysRoleOperationRelaMapper
 * @author admin
 */
@Repository("sysRoleOperationRelaMapper")
public interface SysRoleOperationRelaMapper extends DBActionMapper<SysRoleOperationRelaBean>,
        PaginatingMapper<SysRoleOperationRelaBean>
{

    @Select("select sr.`code`, sou.opn_url as opnUrl " +
            "from sys_role sr " +
            "join sys_role_operation_rela sror on sr.row_id = sror.role_id " +
            "join sys_operation so on so.row_id = sror.opn_id  " +
            "join sys_operation_url sou on sou.opn_id = so.row_id ")
    List<Map<String,Object>> findAllRoleAndOperation();
    
    @Select("select 'COMM' as code , opn_url as opnUrl " +
            "from sys_operation o join sys_operation_url u on u.opn_id = o.row_id " +
            "where o.opn_type = 'COMM' and o.is_deleted = 0 and u.is_deleted = 0 ")
    List<Map<String,Object>> findCommRoleAndOperation();
    
    int deleteBySelective(SysRoleOperationRelaBean sysRoleOperationRelaBean);
}
